package org.example.math;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/20 19:47
 */
public class GcdDemo {

    public static void main(String[] args) {
        GcdDemo gcdDemo = new GcdDemo();
        System.out.println(gcdDemo.gcd(3, 5));
    }

    public int gcd(int a, int b){
        while (b != 0){
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    private int gcd2(int a, int b) {
        return b == 0 ? a : gcd2(b, a % b);
    }


}
